<template>
  <div class="humanFrame">
    <div class="msgDiv">
      <div class="leftDiv" @click="toDetail()">
        <div class="nameDiv">{{ human.name }}</div>
        <!-- <div class="experienceDiv">
					<span>工作经验：</span>
					<span style="color: #d00000">{{human.experience + '年'}}</span>
				</div> -->
        <div class="skillDiv">
          <span>职业技能：</span>
          <span style="color: #d00000">{{ human.skill }}</span>
          <span v-if="type == 1">需求岗位：</span>
          <span v-if="type == 1" style="color: #d00000">{{ human.post }}</span>
        </div>
      </div>
      <div class="rightDiv">
        <div class="labelsDiv">
          <span v-if="(genderLsit && genderLsit.length>0) && human.gender">
            {{ $selectDict(genderLsit, human.gender).dictLabel }}
          </span>
          <span v-if="(workerEducationLsit && workerEducationLsit.length>0) && human.education">
            {{$selectDict(workerEducationLsit, human.education).dictLabel}}
          </span>
          <span>{{ human.age + "岁" }}</span>
        </div>
      </div>
    </div>
    <!-- <div v-if="human.isApply == 1" class="sendBtn2">已申请过</div>
		<div v-if="human.isApply == 0" class="sendBtn" @click="apply">申请简历</div> -->
      <Buttons :buttons="buttons" @apply="apply" @none="''"></Buttons>
    <!-- <div v-if="human.status == 2" class="sendBtn2">已通过</div>
    <div v-if="human.status == 3" class="sendBtn2">已拒绝</div>
    <div v-if="human.status == 1" class="sendBtn2">已申请过</div>
    <div v-if="human.status == 0" class="sendBtn" @click="apply">申请简历</div> -->
  </div>
</template>

<script>
import { uploadFile } from "@/utils/request.js";
import config from "@/utils/config.js";
import { checkLogin, relogin } from "@/utils/util.js";
export default {
  name: "humanFrame",
  props: {
    human: {
      type: Object,
      default: () => {},
    },
    type: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      genderLsit: [],
      workerEducationLsit: []
    };
  },
  computed:{
    buttons(){
      let btnStyle = [];
      if(this.human.status == 2){
        btnStyle.push({text:"已通过",type:"normal",size:"s",method:"none"})
      }else if(this.human.status == 3){
        btnStyle.push({text:"已拒绝",type:"normal",size:"s",method:"none"})
      }else if(this.human.status == 1){
        btnStyle.push({text:"已申请过",type:"normal",size:"s",method:"none"})
      }else if(this.human.status == 0){
        btnStyle.push({text:"申请简历",type:"normal-hover",size:"s",method:"apply"})
      }
      return btnStyle;
    }
  },
  created() {
   this.gettypeList()
  },
  inject: ["showModal"],
  methods: {
    // 字典查询 
    async gettypeList() {
      let api = `gender,worker_education`;
      // 调用公共方法中的查询字典表
      this.getDictList(this, api).then((res) => {
        this.genderLsit = res.gender;
        this.workerEducationLsit = res.worker_education;
      });
    },
    /**
     * 立即申请
     */
    toDetail: function () {
      // console.log(this.human);
      if (this.type == 1) {
        this.$router.push({
          path: "/help/helpAppealList/helpAppealDetail",
          query: { id: this.human.id },
        });
      } else {
        this.$router.push({
          path: "/help/helpHumanList/helpHumanDetail",
          query: { id: this.human.id },
        });
      }
    },
    // 点击申请简历
    apply() {
      if (checkLogin(this)) {
        let formData = new FormData();
        if (this.type == 1) {
          formData.append("id", this.human.workerId);
        } else {
          formData.append("id", this.human.id);
        }
        uploadFile(this, config.api.workerApply, formData).then((res) => {
          if (res.code != "200") return this.$message.warning(res.msg);
          this.showModal(
            "申请简历成功，请耐心等待！",
            require("@/assets/image/success.png")
          );
          this.human.status = 1
        });
      } else {
        relogin(this);
      }
    },
  },
};
</script>

<style scoped>
.humanFrame {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 10px;
  border-bottom: 1px solid #eeeeee;
  transition: all 0.2s ease 0s;
}

.humanFrame:hover {
  box-shadow: 0px 0px 10px #eeeeee;
}

.humanFrame .sendBtn {
  /* padding: 10px 20px; */
  background-color: #f1f2f4;
  color: #045db9;
  white-space: nowrap;
  transition: all 0.2s ease 0s;
  border-radius: 4px;
  width: 90px;
  text-align: center;
  line-height: 30px;
  font-size: 14px;
}

.humanFrame .sendBtn2 {
  /* padding: 10px 20px; */
  background-color: #f1f2f4;
  color: #045db9;
  white-space: nowrap;
  transition: all 0.2s ease 0s;
  border-radius: 4px;
  cursor: pointer;
  width: 90px;
  text-align: center;
  height: 30px;
  line-height: 30px;
  font-size: 14px;
}

.humanFrame .sendBtn:hover {
  padding: 10px 20px;
  background-color: #045db9;
  color: #f1f2f4;
  cursor: pointer;
}

.humanFrame .msgDiv {
  display: flex;
  justify-content: left;
  align-items: center;
  text-align: left;
  width: 100%;
}

.humanFrame .msgDiv .leftDiv {
  width: 60%;
}

.humanFrame .msgDiv .leftDiv:hover {
  cursor: pointer;
}

.humanFrame .msgDiv .leftDiv .nameDiv {
  font-size: 20px;
  font-weight: bold;
  color: #045db9;
  margin-bottom: 15px;
}

.humanFrame .msgDiv .leftDiv .experienceDiv {
  font-size: 14px;
  color: #333333;
}

.humanFrame .msgDiv .rightDiv {
  width: 40%;
}

.humanFrame .msgDiv .rightDiv .labelsDiv {
  margin-bottom: 15px;
}

.humanFrame .msgDiv .rightDiv .labelsDiv span {
  font-size: 12px;
  padding: 5px 10px;
  background-color: #f8f8f8;
  color: #999999;
  margin-right: 5px;
}

.humanFrame .msgDiv .rightDiv .skillDiv {
  font-size: 14px;
  color: #333333;
}
</style>
